using System;
using System.Collections.Generic;
using System.Text;
using IWshRuntimeLibrary;


namespace VoliaStat
{
    public class ShortcutCreator
    {

        public const int CREATED = 1;
        public const int DELETED = 2;
        public const int ERROR = 3;

        static WshShellClass WshShell=null;




        public static int CreateInStartupFolder(string exepath,string exedir)
        {
            int rc=ERROR;
            try
            {   string lnkpath = Environment.GetFolderPath(Environment.SpecialFolder.Startup)+"\\voliastat.lnk";

                if (System.IO.File.Exists(lnkpath))
                {
                    System.IO.File.Delete(lnkpath);
                    rc = DELETED;
                } else
                {
                    string icopath = exedir+"\\volia00.ico";
                    if (WshShell==null) WshShell = new WshShellClass();
                    IWshRuntimeLibrary.IWshShortcut MyShortcut;
                    MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(lnkpath);
                    MyShortcut.TargetPath = exepath;
                    MyShortcut.Description = "Voliastat";
                    MyShortcut.IconLocation = icopath;
                    MyShortcut.Save();
                    rc = CREATED;
                }
            }
            catch
            {          
            }
            
            return rc;

        }


    }
}
